home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / Apple II / Essentials / MPW IIGS Interfaces / PIIGSIncludes / Controls.p < prev    next >
Encoding:
Text File  |  1993-06-15  |  15.6 KB  |  463 lines  |  [TEXT/MPS ]

  1. {********************************************
  2. ; File: Controls.p
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc. 1986-93
  6. ; All Rights Reserved
  7. ;
  8. ********************************************}
  9.  
  10. UNIT CONTROLS;
  11.  
  12. INTERFACE
  13.  
  14. USES TYPES,QUICKDRAW,EVENTS;
  15.  
  16. CONST
  17. { Axis Parameters }
  18. noConstraint = $0000;  { No constraint on movement. }
  19. hAxisOnly = $0001;  { Horizontal axis only. }
  20. vAxisOnly = $0002;  { Vertical axis only. }
  21.  
  22. { CtlFlag }
  23. simpRound = $0000;  { Simple button flag }
  24. upFlag = $0001;  { Scroll bar flag.  }
  25. boldButton = $0001;  { Bold round cornered outlined button. }
  26. simpBRound = $0001;  { Simple button flag }
  27. downFlag = $0002;  { Scroll bar flag. }
  28. simpSquare = $0002;  { Simple button flag }
  29. simpDropSquare = $0003;  { Simple button flag }
  30. leftFlag = $0004;  { Scroll bar flag. }
  31. rightFlag = $0008;  { Scroll bar flag. }
  32. dirScroll = $0010;  { Scroll bar flag. }
  33. horScroll = $0010;  { Scroll bar flag. }
  34. family = $007F;  { Mask for radio button family number }
  35. ctlInVis = $0080;  { invisible mask for any type of control  }
  36. fCallWindowMgr = $0001;  { Control Template flag value }
  37. fSubstituteText = $0002;
  38. fSubTextType = $0001;
  39. inListBox = $88;
  40. fBlastText = $0004; { static text control }
  41. fTextCanDim = $0008; { static text control }
  42. fSquishText = $0010; { static text control }
  43. fNoTrackIcon = $0008; { make icon button play dead }
  44.  
  45. { CtlProc Codes }
  46. simpleProc = $00000000;
  47. checkProc = $02000000;
  48. radioProc = $04000000;
  49. scrollProc = $06000000;
  50. growProc = $08000000;
  51.  
  52. { DefProc Commands }
  53. drawCtl = $0000;  { Draw control command. }
  54. calcCRect = $0001;  { Compute drag RECT command. }
  55. testCtl = $0002;  { Hit test command. }
  56. initCtl = $0003;  { Initialize command. }
  57. dispCtl = $0004;  { Dispose command. }
  58. posCtl = $0005;  { Move indicator command. }
  59. thumbCtl = $0006;  { Compute drag parameters command. }
  60. dragCtl = $0007;  { Drag command. }
  61. autoTrack = $0008;  { Action command. }
  62. newValue = $0009;  { Set new value command. }
  63. setParams = $000A;  { Set new parameters command. }
  64. moveCtl = $000B;  { Move command. }
  65. recSize = $000C;  { Return record size command. }
  66. ctlHandleEvent = $000D;  { Handle a keystroke or menu selection }
  67. ctlChangeTarget = $000E;  { Issued when control's target status has changed }
  68. ctlChangeBounds = $000F;  { Issued when control's boundary rectangle has changed }
  69. ctlWindChangeSize = $0010;  { Window has been grown or zoomed }
  70. ctlHandleTab = $0011;  { Control has been tabbed to }
  71. ctlNotifyMultiPart = $0012;  { A multipart control has been hidden, drawn or shown }
  72. ctlWinStateChange = $0013;  { Window state has changed }
  73.  
  74. { hiliteState Codes }
  75. noHilite = $0000;  { Param to HiliteControl }
  76. inactiveHilite = $00FF;  { Param to HiliteControl }
  77.  
  78. { PartCode Numbers }
  79. noPart = $0000;
  80. simpleButton = $0002;
  81. checkBox = $0003;
  82. radioButton = $0004;
  83. upArrow = $0005;
  84. downArrow = $0006;
  85. pageUp = $0007;
  86. pageDown = $0008;
  87. growBox = $000A;
  88. thumb = $0081;
  89.  
  90. { moreFlags Codes }
  91. fCtlTarget = $8000;  { is current target of typing commands }
  92. fCtlCanBeTarget = $4000;  { can be made the target control }
  93. fCtlWantEvent = $2000;  { control can be called view SendEventToCtl }
  94. fCtlWantsEvent = $2000;  { control can be called view SendEventToCtl }
  95. fCtlWantEvents = $2000;  { control can be called view SendEventToCtl }
  96. fCtlWantsEvents = $2000;  { control can be called view SendEventToCtl }
  97. fCtlProcRefNotPtr = $1000;  { set = ID of defproc, clear = pointer to defproc }
  98. fCtlTellAboutSize = $0800;  { set if ctl needs notification when size of owning window changes }
  99. fCtlIsMultiPart = $0400;  { set if ctl needs notification to be hidden }
  100. fMenuDefIsText = $0004;
  101. fDrawIconInResult = $0020;
  102. fDrawPopDownIcon = $0080;
  103. colorDescriptor = $000C;  { indicates type of reference in colorRef }
  104. styleDescriptor = $0003;  { indicates type of reference in styleRef }
  105.  
  106. { Ctl Verbs }
  107. titleIsPtr = $00;
  108. titleIsHandle = $01;
  109. titleIsResource = $02;
  110. colorTableIsPtr = $00;
  111. colorTableIsHandle = $04;
  112. colorTableIsResource = $08;
  113. ctlHideCtl = $12;
  114.  
  115. { InputVerb Codes }
  116. singlePtr = $0000;
  117. singleHandle = $0001;
  118. singleResource = $0002;
  119. ptrToPtr = $0003;
  120. ptrToHandle = $0004;
  121. ptrToResource = $0005;
  122. handleToPtr = $0006;
  123. handleToHandle = $0007;
  124. handleToResource = $0008;
  125. resourceToResource = $0009;
  126.  
  127. { ProcRefs }
  128. simpleButtonControl = $80000000;
  129. checkControl = $82000000;
  130. radioControl = $84000000;
  131. scrollBarControl = $86000000;
  132. growControl = $88000000;
  133. statTextControl = $81000000;
  134. editLineControl = $83000000;
  135. editTextControl = $85000000;
  136. popUpControl = $87000000;
  137. listControl = $89000000;
  138. pictureControl = $8D000000;
  139. iconButtonControl = $87FF0001;
  140. thermometerControl = $87FF0002;
  141. rectangleControl = $87FF0003;
  142.  
  143.  
  144. { Error Codes }
  145. wmNotStartedUp = $1001;  { Window manager was not initialized }
  146. cmNotInitialized = $1002;  { Control manager was not initialized }
  147. noCtlInList = $1003;  { Control not in window list }
  148. noCtlError = $1004;  { no controls in window }
  149. noSuperCtlError = $1005;  { no super controls in window }
  150. noCtlTargetError = $1006;  { no target super control }
  151. notSuperCtlError = $1007;  { action can only be done on super control }
  152. canNotBeTargetError = $1008;  { conrol cannot be made target }
  153. noSuchIDError = $1009;  { specified ID cannot be found }
  154. tooFewParmsError = $100A;  { not enough params specified }
  155. noCtlToBeTargetError = $100B;  { NextCtl call, no ctl could be target }
  156. noFrontWindowError = $100C;  { there is no front window }
  157.  
  158. { displayMode flags }
  159. selectedIcon = $0001;
  160. openIcon = $0002;
  161. offline = $0004;
  162.  
  163. { listType values }
  164. fListString = $0001;
  165. fListSelect = $0002;
  166. fListScrollBar = $0004;
  167.  
  168. { PopUp control flag values }
  169. fRightJustifyResult = $0001;
  170. fRightJustifyTitle = $0002;
  171. fInWindowOnly = $0004;
  172. fDontDrawResult = $0008;
  173. fDontDrawTitle = $0010;
  174. fDontHiliteTitle = $0020;
  175. fType2PopUp = $0040;
  176.  
  177. TYPE
  178. {$IFC UNDEFINED WindowPtr }
  179. WindowPtr = GrafPortPtr ;
  180. {$SETC WindowPtr := 0 }
  181. {$ENDC}
  182.  
  183.  
  184. BarColorsHndl = ^BarColorsPtr;
  185. BarColorsPtr = ^BarColors;
  186. BarColors = RECORD
  187.     barOutline : Integer; { color for outlining bar, arrows, and thumb }
  188.     barNorArrow : Integer; { color of arrows when not highlighted }
  189.     barSelArrow : Integer; { color of arrows when highlighted }
  190.     barArrowBack : Integer; { color of arrow box's background }
  191.     barNorThumb : Integer; { color of thumb's background when not highlighted }
  192.     barSelThumb : Integer; { color of thumb's background when highlighted }
  193.     barPageRgn : Integer; { color and pattern page region: high byte - 1= dither, 0 = solid }
  194.     barInactive : Integer; { color of scroll bar's interior when inactive }
  195. END;
  196.  
  197. BoxColorsHndl = ^BoxColorsPtr;
  198. BoxColorsPtr = ^BoxColors;
  199. BoxColors = RECORD
  200.     boxReserved : Integer; { reserved }
  201.     boxNor : Integer; { color of box when not checked }
  202.     boxSel : Integer; { color of box when checked }
  203.     boxTitle : Integer; { color of check box's title }
  204. END;
  205.  
  206. BttnColorsHndl = ^BttnColorsPtr;
  207. BttnColorsPtr = ^BttnColors;
  208. BttnColors = RECORD
  209.     bttnOutline : Integer; { color of outline }
  210.     bttnNorBack : Integer; { color of background when not selected }
  211.     bttnSelBack : Integer; { color of background when selected }
  212.     bttnNorText : Integer; { color of title's text when not selected }
  213.     bttnSelText : Integer; { color of title's text when selected }
  214. END;
  215.  
  216. CtlRecHndlPtr = ^CtlRecHndl;
  217. CtlRecHndl = ^CtlRecPtr;
  218. CtlRecPtr = ^CtlRec;
  219. CtlRec = PACKED RECORD
  220.     ctlNext : CtlRecHndl; { Handle of next control. }
  221.     ctlOwner : WindowPtr; { Pointer to control's window. }
  222.     ctlRect : Rect; { Enclosing rectangle. }
  223.     ctlFlag : Byte; { Bit flags. }
  224.     ctlHilite : Byte; { Highlighted part. }
  225.     ctlValue : Integer; { Control's value. }
  226.     ctlProc : LongProcPtr; { Control's definition procedure. }
  227.     ctlAction : LongProcPtr; { Control's action procedure. }
  228.     ctlData : Longint; { Reserved for CtrlProc's use. }
  229.     ctlRefCon : Longint; { Reserved for application's use. }
  230.     ctlColor : Ptr; { Pointer to appropriate color table. }
  231.     ctlReserved : PACKED ARRAY[1..16] OF Byte; { Reserved for future expansion }
  232.     ctlID : Longint;
  233.     ctlMoreFlags : Integer;
  234.     ctlVersion : Integer;
  235. END;
  236.  
  237. LimitBlkHndl = ^LimitBlkPtr;
  238. LimitBlkPtr = ^LimitBlk;
  239. LimitBlk = RECORD
  240.     boundRect : Rect; { Drag bounds. }
  241.     slopRect : Rect; { Cursor bounds. }
  242.     axisParam : Integer; { Movement constrains. }
  243.     dragPatt : Ptr; { Pointer to 32 byte Pattern for drag outline. }
  244. END;
  245.  
  246. RadioColorsHndl = ^RadioColorsPtr;
  247. RadioColorsPtr = ^RadioColors;
  248. RadioColors = RECORD
  249.     radReserved : Integer; { reserved }
  250.     radNor : Integer; { color of radio button when off }
  251.     radSel : Integer; { color of radio button when on }
  252.     radTitle : Integer; { color of radio button's title text }
  253. END;
  254.  
  255. KeystrokeRec = PACKED RECORD
  256.     key1 : Byte;
  257.     key2 : Byte;
  258.     keyModifiers : Integer;
  259.     keyCareBits : Integer;
  260. END;
  261.  
  262. ControlTemplate = RECORD
  263.     pCount : Integer;
  264.     ID : Longint;
  265.     rect : Rect;
  266.     procRef : Longint;
  267.     flag : Integer;
  268.     moreFlags : Integer;
  269.     refCon : Longint;
  270. END;
  271.  
  272. SimpleButtonTemplate = RECORD
  273.     ctlTemplate : ControlTemplate;
  274.     titleRef : Ref;
  275.     colorTableRef : Ref;
  276.     keyEquivalent : KeystrokeRec;
  277. END;
  278.  
  279. CheckBoxTemplate = RECORD
  280.     ctlTemplate : ControlTemplate;
  281.     titleRef : Ref;
  282.     initalValue : Integer;
  283.     colorTableRef : Ref;
  284.     keyEquivalent : KeystrokeRec;
  285. END;
  286.  
  287. IconButtonTemplate = RECORD
  288.     ctlTemplate : ControlTemplate;
  289.     iconRef : Ref;
  290.     titleRef : Ref;
  291.     colorTableRef : Ref;
  292.     displayMode : Integer;
  293.     keyEquivalent : KeystrokeRec;
  294. END;
  295.  
  296. LineEditTemplate = RECORD
  297.     ctlTemplate : ControlTemplate;
  298.     maxSize : Integer;
  299.     defaultRef : Ref;
  300.     passwordChar: Integer;
  301. END;
  302.  
  303. ListTemplate = RECORD
  304.     ctlTemplate : ControlTemplate;
  305.     listSize : Integer;
  306.     listView : Integer;
  307.     listType : Integer;
  308.     listStart : Integer;
  309.     listDraw : ProcPtr;
  310.     listMemHeight : Integer;
  311.     listMemSize : Integer;
  312.     listRef : Ref;
  313.     colorTableRef : Ref;
  314. END;
  315.  
  316. PictureTemplate = RECORD
  317.     ctlTemplate : ControlTemplate;
  318.     pictureRef : Ref;
  319. END;
  320.  
  321. PopupTemplate = RECORD
  322.     ctlTemplate : ControlTemplate;
  323.     titleWidth : Integer;
  324.     menuRef : Ref;
  325.     initialValue : Integer;
  326.     colorTableRef : Ref;
  327. END;
  328.  
  329. RadioButtonTemplate = RECORD
  330.     ctlTemplate : ControlTemplate;
  331.     titleRef : Ref;
  332.     initalValue : Integer;
  333.     colorTableRef : Ref;
  334.     keyEquivalent : KeystrokeRec;
  335. END;
  336.  
  337. RectangleTemplate = RECORD
  338.     ctlTemplate: ControlTemplate;
  339.     penHeight: integer;
  340.     penWidth: integer;
  341.     penMask: Mask;
  342.     penPattern: Pattern;
  343. END;
  344.  
  345. ScrollBarTemplate = RECORD
  346.     ctlTemplate : ControlTemplate;
  347.     maxSize : Integer;
  348.     viewSize : Integer;
  349.     initalValue : Integer;
  350.     colorTableRef : Ref;
  351. END;
  352.  
  353. SizeBoxTemplate = RECORD
  354.     ctlTemplate : ControlTemplate;
  355.     colorTableRef : Ref;
  356. END;
  357.  
  358. StaticTextTemplate = RECORD
  359.     ctlTemplate : ControlTemplate;
  360.     textRef : Ref;
  361.     textSize : Integer;
  362.     just : Integer;
  363. END;
  364.  
  365. TextEditTemplate = RECORD
  366.     ctlTemplate : ControlTemplate;
  367.     textFlags : Longint;
  368.     indentRect : Rect;
  369.     vertBar : CtlRecHndl;
  370.     vertAmount : Integer;
  371.     horzBar : CtlRecHndl;
  372.     horzAmount : Integer;
  373.     styleRef : Ref;
  374.     textDescriptor : Integer;
  375.     textRef : Ref;
  376.     textLength : Longint;
  377.     maxChars : Longint;
  378.     maxLines : Longint;
  379.     maxCharsPerLine : Integer;
  380.     maxHeight : Integer;
  381.     colorRef : Ref;
  382.     drawMode : Integer;
  383.     filterProcPtr : ProcPtr;
  384. END;
  385.  
  386. ThermometerTemplate = RECORD
  387.     ctlTemplate: ControlTemplate;
  388.     value: integer;
  389.     data: integer;
  390.     colorTableRef: Ref;
  391. END;
  392.  
  393. FUNCTION  CallCtlDefProc ( ctlHandle:CtlRecHndl; ctlMessage:Integer; ctlParam:Longint) : Longint ;
  394. FUNCTION  CMLoadResource ( resourceType:Integer; resourceID:Longint) : Handle ;
  395. PROCEDURE CMReleaseResource ( resourceType:Integer; resourceID:Longint)  ;
  396. PROCEDURE CtlBootInit   ;
  397. PROCEDURE CtlNewRes   ;
  398. PROCEDURE CtlReset   ;
  399. PROCEDURE CtlShutDown   ;
  400. PROCEDURE CtlStartUp ( userID:Integer; dPageAddr:Integer)  ;
  401. FUNCTION  CtlStatus  : Boolean ;
  402. FUNCTION  CtlVersion  : Integer ;
  403. PROCEDURE DisposeControl ( theControlHandle:CtlRecHndl)  ;
  404. PROCEDURE DragControl ( startX:Integer; startY:Integer; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer; theControlHandle:CtlRecHndl)  ;
  405. FUNCTION  DragRect ( actionProcPtr:VoidProcPtr; dragPatternPtr:Pattern; startX:Integer; startY:Integer;VAR dragRectPtr:Rect; limitRectPtr:Rect; slopRectPtr:Rect; dragFlag:Integer) : Point ;
  406. PROCEDURE DrawControls ( theWindowPtr:WindowPtr)  ;
  407. PROCEDURE DrawOneCtl ( theControlHandle:CtlRecHndl)  ;
  408. PROCEDURE EraseControl ( theControlHandle:CtlRecHndl)  ;
  409. FUNCTION  FindControl (VAR foundCtl:CtlRecHndl; pointX:Integer; pointY:Integer; theWindowPtr:WindowPtr) : Integer ;
  410. FUNCTION  FindTargetCtl  : CtlRecHndl ;
  411. FUNCTION  GetCtlAction ( theControlHandle:CtlRecHndl) : LongProcPtr ;
  412. FUNCTION  GetCtlDPage  : Integer ;
  413. FUNCTION  GetCtlHandleFromID ( ctlWindowPtr:WindowPtr; ctlID:Longint) : CtlRecHndl ;
  414. FUNCTION  GetCtlID ( ctlHandle:CtlRecHndl) : Longint ;
  415. FUNCTION  GetCtlMoreFlags ( ctlHandle:CtlRecHndl) : Integer ;
  416. FUNCTION  GetCtlParamPtr  : Ptr ;
  417. FUNCTION  GetCtlParams ( theControlHandle:CtlRecHndl) : Longint ;
  418. FUNCTION  GetCtlRefCon ( theControlHandle:CtlRecHndl) : Longint ;
  419. FUNCTION  GetCtlTitle ( theControlHandle:CtlRecHndl) : Ptr ;
  420. FUNCTION  GetCtlValue ( theControlHandle:CtlRecHndl) : Integer ;
  421. FUNCTION  GrowSize  : Longint ;
  422. PROCEDURE HideControl ( theControlHandle:CtlRecHndl)  ;
  423. PROCEDURE HiliteControl ( hiliteState:Integer; theControlHandle:CtlRecHndl)  ;
  424. PROCEDURE InvalCtls ( ctlWindowPtr:WindowPtr)  ;
  425. PROCEDURE KillControls ( theWindowPtr:WindowPtr)  ;
  426. FUNCTION  MakeNextCtlTarget  : CtlRecHndl ;
  427. PROCEDURE MakeThisCtlTarget ( ctlToBeTarget:CtlRecHndl)  ;
  428. PROCEDURE MoveControl ( newX:Integer; newY:Integer; theControlHandle:CtlRecHndl)  ;
  429. FUNCTION  NewControl ( theWindowPtr:WindowPtr; boundsRectPtr:Rect; titlePtr:Ptr; flag:Integer; value :Integer; param1:Integer; param2:Integer; defProcPtr:LongProcPtr; refCon:Longint; newColorTablePtr:ColorTablePtr) : CtlRecHndl ;
  430. FUNCTION  NewControl2 ( ownerPtr:WindowPtr; inputDesc:RefDescriptor; inputRef:Ref) : CtlRecHndl ;
  431. PROCEDURE NotifyControls ( notifyMask:Integer; message:Integer; notifyParam:Longint; window:WindowPtr)  ;
  432. PROCEDURE NotifyCtls ( moreFlagsMask:Integer; ctlMessage:Integer; ctlParam:Longint; theWindowPtr:WindowPtr)  ;
  433. FUNCTION  SendEventToCtl ( targetOnlyFlag:Integer; ctlWindowPtr:WindowPtr; eTaskRecPtr:Ptr) : Boolean ;
  434. PROCEDURE SetCtlAction ( newActionPtr:LongProcPtr; theControlHandle:CtlRecHndl)  ;
  435. FUNCTION  SetCtlIcons ( newFontHandle:FontHndl) : FontHndl ;
  436. PROCEDURE SetCtlID ( newID:Longint; ctlHandle:CtlRecHndl)  ;
  437. PROCEDURE SetCtlMoreFlags ( newMoreFlags:Integer; ctlHandle:CtlRecHndl)  ;
  438. PROCEDURE SetCtlParamPtr ( SubArrayPtr:Ptr)  ;
  439. PROCEDURE SetCtlParams ( param2:Integer; param1:Integer; theControlHandle:CtlRecHndl)  ;
  440. PROCEDURE SetCtlRefCon ( newRefCon:Longint; theControlHandle:CtlRecHndl)  ;
  441. PROCEDURE SetCtlTitle ( title:Str255; theControlHandle:CtlRecHndl)  ;
  442. PROCEDURE SetCtlValue ( curValue:Integer; theControlHandle:CtlRecHndl)  ;
  443. PROCEDURE ShowControl ( theControlHandle:CtlRecHndl)  ;
  444. FUNCTION  TestControl ( pointX:Integer; pointY:Integer; theControlHandle:CtlRecHndl) : Integer ;
  445. FUNCTION  TrackControl ( startX:Integer; startY:Integer; actionProcPtr:LongProcPtr; theControlHndl:CtlRecHndl) : Integer ;
  446.  
  447. FUNCTION FindRadioButton(theWindow:WindowPtr; theFamily:integer): integer;
  448. PROCEDURE SetLETextByID(theWindow:WindowPtr; theID:longint; s:StringPtr);
  449. PROCEDURE GetLETextByID(theWindow:WindowPtr; theID:longint; s:StringPtr);
  450.  
  451. PROCEDURE SetCtlValueByID (curValue:Integer; theWindow:WindowPtr; theID:longint);
  452.   INLINE $A2,$3C10,$22,$E10000,$8F,'_toolErr';
  453. FUNCTION  GetCtlValueByID (theWindow:WindowPtr; theID:longint) : Integer ;
  454.   INLINE $A2,$3D10,$22,$E10000,$8F,'_toolErr';
  455. PROCEDURE InvalOneCtlByID (theWindow:WindowPtr; theID:longint);
  456.   INLINE $A2,$3E10,$22,$E10000,$8F,'_toolErr';
  457. PROCEDURE HiliteCtlByID (hiliteState:Integer; theWindow:WindowPtr; theID:longint);
  458.   INLINE $A2,$3F10,$22,$E10000,$8F,'_toolErr';
  459.  
  460. IMPLEMENTATION
  461.  
  462. END.
  463.